package com.zzyl.controller;

import com.zzyl.base.ResponseResult;
import com.zzyl.dto.FloorDto;
import com.zzyl.service.FloorService;
import com.zzyl.vo.FloorVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/floor")
@Api(tags = "楼层管理")
public class FloorController extends BaseController {

    @Autowired
    private FloorService floorService;


//    @PostMapping("/add")
//    @ApiOperation(value = "添加楼层",notes = "传入楼层信息，返回结果" )
//    public  ResponseResult addFloor(@RequestBody FloorDto floorDto){
//        return success( floorService.addFloor(floorDto));
//    }

    /**
     * 添加楼层
     * @param floorDto
     * @return
     */
    @ApiOperation("添加楼层")
    @PostMapping("/add")
    public  ResponseResult addFloor(@RequestBody @ApiParam("新增楼层信息") FloorDto floorDto){
        floorService.addfloor(floorDto);
        return success();
    }

//    @DeleteMapping("/delete/{id}")
//    @ApiOperation(value = "删除楼层", notes = "根据楼层id删除指定楼层，返回删除结果")
//    public ResponseResult deleteFloor(@PathVariable Long id) {
//        floorService.deleteFloor(id);
//        return success();
//    }
    @DeleteMapping("/delete/{id}")
    @ApiOperation("根据id删除楼层")
    public ResponseResult deleteFloor(@PathVariable @ApiParam("删除楼层id") Long id){
        floorService.deletefloor(id);
        return success();
    }

//    @PutMapping("/update")
//    @ApiOperation(value = "更新楼层", notes = "传入更新的楼层信息，返回更新结果")
//    public ResponseResult updateFloor(@RequestBody FloorDto floorDto) {
//        floorService.updateFloor(floorDto);
//        return success();
//    }
    @PutMapping("/update")
    @ApiOperation(("更新楼层"))
    public ResponseResult updateFloor(@RequestBody @ApiParam("更新楼层信息") FloorDto floorDto){
        floorService.updatefloor(floorDto);
        return success();
    }

//    @GetMapping("/get/{id}")
//    @ApiOperation(value = "获取楼层", notes = "根据楼层id获取指定楼层，返回楼层信息")
//    public ResponseResult<FloorVo> getFloor(@PathVariable Long id) {
//        return success(floorService.getFloor(id));
//    }
    @GetMapping("/get/{id}")
    @ApiOperation(value = "根据id查询楼层",notes = "根据楼层id获取指定楼层信息")
    public ResponseResult<FloorVo> GetByIdFloor(@PathVariable @ApiParam("楼层id") Long id){
        return success(floorService.GetByidFloor(id));
    }

//    @GetMapping("/getAll")
//    @ApiOperation(value = "获取所有楼层", notes = "无需参数，获取所有楼层，返回楼层信息列表")
//    public ResponseResult<List<FloorVo>> getAllFloors() {
//        return success(floorService.getAllFloors());
//    }

    @GetMapping("/getAll")
    @ApiOperation(value = "查询所有楼层" ,notes = "查询所有楼层信息")
    public ResponseResult<List<FloorVo>> GetAllFloor(){
        List<FloorVo> floorVoList =  floorService.getFloorAll();
        return success(floorVoList);
    }

    @GetMapping("/getAllFloorsWithNur")
    @ApiOperation(value = "获取所有楼层 (负责老人)", notes = "无需参数，获取所有楼层，返回楼层信息列表")
    public ResponseResult<List<FloorVo>> getAllFloorsWithNur() {
        return success(floorService.selectAllByNur());
    }

    @GetMapping("/getAllWithRoomAndBed")
    @ApiOperation(value = "获取所有楼层 （包含房间和床位）", notes = "无需参数，获取所有楼层，返回楼层信息列表")
    public ResponseResult<List<FloorVo>> getAllWithRoomAndBed() {
        return success(floorService.getAllWithRoomAndBed());
    }

}
